package com.alien.admin.modules.basic.service;

import com.alien.admin.modules.deploy.domain.DpJenkinsInstance;

/**
 * @description: Jenkins构建接口
 * @author: zhouseyi
 * @date: 2021/9/23 19:56
 * @version: 1.0
 */
public interface JenkinsService {

    /***
     * 获取job是否存在
     * @param instance
     * @param jobName
     * @return 是否存在
     */
    boolean hasJob(DpJenkinsInstance instance, String jobName);

    /***
     * 获取job最后一次编译是否成功
     * @param instance
     * @param jobName
     * @return 是否成功
     */
    boolean getLastBuild(DpJenkinsInstance instance, String jobName);

    /***
     * 进行构建
     * @param instance
     * @param jobName
     * @param params
     * @return 成功返回queueId，失败返回-1
     */
    Integer buildJob(DpJenkinsInstance instance, String jobName, String params);

    /***
     * 获取构建结果
     * @param instance
     * @param jobName
     * @param queueId
     * @return 1-部署中2-失败3-成功
     */
    Integer getBuildResult(DpJenkinsInstance instance, String jobName, Long queueId);

    /***
     * 获取构建日志
     * @param instance
     * @param jobName
     * @param queueId
     */
    String getBuildLog(DpJenkinsInstance instance, String jobName, Long queueId);

    /***
     * 创建job
     * @param instance
     * @param jobName
     * @param jobContent
     * @return 返回是否成功
     */
    boolean createJob(DpJenkinsInstance instance, String jobName, String jobContent);
}
